define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'goods_customer/index' + location.search,
                    add_url: 'goods_customer/add',
                    edit_url: 'goods_customer/edit',
                    del_url: 'goods_customer/del',
                    multi_url: 'goods_customer/multi',
                    import_url: 'goods_customer/import',
                    table: 'goods_customer',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'goods_id', title: __('Goods_id')},
                        {field: 'goods.name', title: __('线路')},
                        {field: 'goods.goods_no', title: __('线路编号')},
                        {field: 'user_join_num_add', title: __('会员上会次数增加'),visible:false},
                        {field: 'user_id', title: __('User_id')},
                        {field: 'username', title: __('Username'), operate: 'LIKE'},
                        {field: 'user.join_num', title: __('User.join_num')},
                        {field: 'user.level', title: __('User.level'), searchList: {"0":__("非会员"),"1":__('悦享游会员'),"2":__('尊享游会员'),"3":__('裕鹅会员'),}, formatter: Table.api.formatter.normal},
                        {field: 'idcard', title: __('Idcard'), operate: 'LIKE'},
                        {field: 'age', title: __('Age')},
                        {field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
                        {field: 'gender', title: __('Gender'), searchList: {"1":__('Gender 1'),"0":__('Gender 0')}, formatter: Table.api.formatter.normal},
                        {field: 'nation', title: __('Nation'), operate: 'LIKE'},
                        {field: 'remark', title: __('Remark'), operate: 'LIKE'},
                      //  {field: 'office_id', title: __('Office_id')},
                        {field: 'branchofficeoffice.name', title: __('报名分公司')},
                        //{field: 'shop_id', title: __('Shop_id')},
                        {field: 'manystoreshop.name', title: __('报名门店')},
                        //{field: 'store_id', title: __('销售ID')},
                        {field: 'manystore.username', title: __('报名销售')},
                        {field: 'updatetime', title: __('Updatetime')},
                        {field: 'createtime', title: __('Createtime')},

                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,


                        }
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        batch_import: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});